/*
 * Copyright 2010-2011 Sanjay Dwivedi.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.isdinvestments.cam.domain.model;

import java.io.Serializable;
import javax.persistence.*;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import java.util.Date;
import java.util.Set;


/**
 * The Portfolio entity. An Account or SubAccount can have one or more portfolios.
 * 
 */
@Entity
public class Portfolio implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="PORTFOLIO_ID_GENERATOR", sequenceName="PORTFOLIO_ID_SEQ")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="PORTFOLIO_ID_GENERATOR")
	private long id;

	@Column(name="CREATED_BY")
	private String createdBy;

    @Temporal( TemporalType.DATE)
	@Column(name="CREATED_DATE")
	private Date createdDate;

	private String name;

	@Column(name="UPDATED_BY")
	private String updatedBy;

    @Temporal( TemporalType.DATE)
	@Column(name="UPDATED_DATE")
	private Date updatedDate;

	//bi-directional many-to-one association to Account
    @ManyToOne
	@JoinColumn(name="SUB_ACCOUNT_ID")
	private Account account;

	//bi-directional many-to-one association to ReferenceData
    @ManyToOne
	@JoinColumn(name="STATUS")
	private PortfolioStatus portfolioStatus;

	//bi-directional many-to-one association to ReferenceData
    @ManyToOne
	@JoinColumn(name="PORTFOLIO_TYPE")
	private PortfolioType portfolioType;

	//bi-directional many-to-one association to Position
	@OneToMany(mappedBy="portfolio", cascade = { CascadeType.ALL })
//	@Basic(fetch = FetchType.EAGER)
	@Fetch(FetchMode.JOIN)
	@LazyCollection(LazyCollectionOption.FALSE)
	private Set<Position> positions;

    public Portfolio() {
    }

	public long getId() {
		return this.id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getCreatedBy() {
		return this.createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUpdatedBy() {
		return this.updatedBy;
	}

	public void setUpdatedBy(String updatedBy) {
		this.updatedBy = updatedBy;
	}

	public Date getUpdatedDate() {
		return this.updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	public Account getAccount() {
		return this.account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}
	
	public PortfolioStatus getReferenceData1() {
		return this.portfolioStatus;
	}

	public void setPortfolioStatus(PortfolioStatus status) {
		this.portfolioStatus = status;
	}
	
	public PortfolioType getPortfolioType() {
		return this.portfolioType;
	}

	public void setPortfolioType(PortfolioType type) {
		this.portfolioType = type;
	}
	
	public Set<Position> getPositions() {
		return this.positions;
	}

	public void setPositions(Set<Position> positions) {
		this.positions = positions;
	}
	
}